package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.BizPandianLog;
import com.ruoyi.system.service.IBizPandianLogService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 清查日志Controller
 * 
 * @author ruoyi
 * @date 2024-12-19
 */
@Controller
@RequestMapping("/system/pandianlog")
public class BizPandianLogController extends BaseController
{
    private String prefix = "system/pandianlog";

    @Autowired
    private IBizPandianLogService bizPandianLogService;

    @RequiresPermissions("system:pandianlog:view")
    @GetMapping()
    public String pandianlog()
    {
        return prefix + "/pandianlog";
    }

    /**
     * 查询清查日志列表
     */
    @RequiresPermissions("system:pandianlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BizPandianLog bizPandianLog)
    {
        startPage();
        List<BizPandianLog> list = bizPandianLogService.selectBizPandianLogList(bizPandianLog);
        return getDataTable(list);
    }

    /**
     * 导出清查日志列表
     */
    @RequiresPermissions("system:pandianlog:export")
    @Log(title = "清查日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BizPandianLog bizPandianLog)
    {
        List<BizPandianLog> list = bizPandianLogService.selectBizPandianLogList(bizPandianLog);
        ExcelUtil<BizPandianLog> util = new ExcelUtil<BizPandianLog>(BizPandianLog.class);
        return util.exportExcel(list, "清查日志数据");
    }

    /**
     * 新增清查日志
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存清查日志
     */
    @RequiresPermissions("system:pandianlog:add")
    @Log(title = "清查日志", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BizPandianLog bizPandianLog)
    {
        return toAjax(bizPandianLogService.insertBizPandianLog(bizPandianLog));
    }

    /**
     * 修改清查日志
     */
    @RequiresPermissions("system:pandianlog:edit")
    @GetMapping("/edit/{sn}")
    public String edit(@PathVariable("sn") Long sn, ModelMap mmap)
    {
        BizPandianLog bizPandianLog = bizPandianLogService.selectBizPandianLogBySn(sn);
        mmap.put("bizPandianLog", bizPandianLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存清查日志
     */
    @RequiresPermissions("system:pandianlog:edit")
    @Log(title = "清查日志", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BizPandianLog bizPandianLog)
    {
        return toAjax(bizPandianLogService.updateBizPandianLog(bizPandianLog));
    }

    /**
     * 删除清查日志
     */
    @RequiresPermissions("system:pandianlog:remove")
    @Log(title = "清查日志", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(bizPandianLogService.deleteBizPandianLogBySns(ids));
    }
}
